package com.seal.tsms.base.aop;

import com.seal.tsms.base.log.BaseLog;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.Signature;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

/**
 * aop 切面
 * 方法日志处理切面
 * Created by seal.jing on 2015/12/22.
 */
@Component
@Aspect
public class MethodLogAop extends BaseLog {

    /**
     * 环绕通知
     * 切入到项目中所有方法上
     * @param pj
     * @return
     * @throws Throwable
     */
    //@Around("execution(* com.seal.tsms..*.*(..))")
    public Object before(ProceedingJoinPoint pj) throws Throwable {

       Object target= pj.getTarget();
       Signature signature = pj.getSignature();
        String targetClassName=target.getClass().getSimpleName();
        String targetMethodName=signature.getName();
        log.debug("开始执行 "+targetClassName+" 类的 "+targetMethodName +"方法");
        Object o=pj.proceed();
        log.debug(targetClassName+" 类的 "+targetMethodName +"方法执行完成");
       return  o;

    }


}
